//package com.qf.utils;//package com.qf.utils;
//
//
//import com.alibaba.fastjson.JSONObject;
//import com.alipay.api.AlipayApiException;
//import com.alipay.api.AlipayClient;
//import com.alipay.api.DefaultAlipayClient;
//import com.alipay.api.internal.util.AlipaySignature;
//import com.alipay.api.request.AlipayTradePagePayRequest;
//import com.qf.springbootrediscrud.pojo.TbSeckillOrder;
//
//import javax.servlet.http.HttpServletRequest;
//import java.util.HashMap;
//import java.util.Map;
//import java.util.Set;
//
//public class AlipayUtils {
//
//
//   private final static String serverUrl="https://openapi.alipaydev.com/gateway.do";
//   private final static String appId="2016101800712391";
//   private final static String appPrivateKey="MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDdS4iYMEnboDsJ+uxOyZI5xaUp3iX3R9aX3kf4CD0f8bbimxw2IE1XRjwgwNEuw6z8SPy1/HWouPHHyPn8iwfGGTS2RfkQCCX1pMxXD+1KOKbQS6f3B1IU0Ab1N2r0bKGSnH3KRipp9WmCbT+Oy4XfW1fUlkztVzCrjLITgnpLUBsq1StaJFo8mLngfH3GKpe4qJbAPZXoTYcCbr5LdUoXhJQQzRG5oV2FGlGbTiNCJKctfSIeEPKC7M1bP5BJXFOZFVJIlOnkX4QIqNxxw3jJTg1lGYQkBRBmUiR0sGwQS8jAU3GNlXHFYGvUBhpiFlzqJ9aMBfWuYiAOkUcxD6sxAgMBAAECggEAbNsxEBwA2OaS5C/oekExivWsb1H1vxQ5fW88W8hBuSr/2ayPThjJsrq77SisPaLHvzpwBV1wy1ReqvYz8oS5iDrx8Q+umrJHafRtCA6vnSkM9b2hnCSfvdku8wUVubKOMD6Gqi+lwYWVJzFyaF25NswKAmsE4GNZb6nAF1TBr7WHV8e5rzOexxC7TdCxQem3d8ZYHHMVK7Kf8GEZlFOMgQeOLkj2LGgAqbqr697H9ijyFGoXJHWOHlr8ggtZ8+ADqtlWQHqNPUDhGjptjJuzZqz+xo47M6UZ5MnU9AeK2xjRzWHvjBS31TyrLmocL/frrnS0Uy3CPQ6zupNwfCUOIQKBgQD+bfseUd1i+NH5f34sa85oQPvN1M+KtvC+bvDO+871JQh7jV5oZ/bPFnyATIa7QY2zkvlMt30ZlWvtdY0mm+0BVRwQuBkplwfXq+E8P6xC3TQC9vFyoFB79twOMDITwbE0ZK+Y5xoVtMDLP+KOJVT+O0DXiSv/7qJYAp/H8jEglQKBgQDeqTKIeY1i5AtXpkEbw0COTV362JGPAZdj+OvWdeZ0zTmzLCLqxfOzJzNxjTR7/Xg33nTQF38BeZKjun/UPDKDZa7TK8EP2yKLqzE99UDOIZa3xMi/T5QjBhZSQSeHDud48bnRxfk5ZSinHQfIEFEmunYV7fthS2w8i8RuhnftLQKBgQCkUbd7L3gBsZ06u8JrQfz+i+mUV7rqZZg6BUB1DV/uJ0rBMN4mI+7cdDNYURQ63+16apOjnmWnHj+kDuVoaA+7apJDogJuP+KKwbEnzh+c12v99iqd0zfnt9kLOMk+xTuDEPvvjmHkXuac3ded4jJwNyh7i1XlZuNmX9t9sMdVuQKBgFaDd1b/o6fg42dS+clHvDWOag2lSClAfQojFb9mX/zSILE1XPvLnjzl5l8gdlwWyDctAEY6Wua/zfI/7JsSKK5VO/Bg98qpYmrSQXfJazysYFtW4oky6mQRYWrkVe9sIxQjGAgh3Awo+fq0lOlvLZjWqjsrFJlhLNT5mYE4TjChAoGBAPd5XpxWMgRUaQJJZ34I1OKc+CUM6dbb+nBXvXc8o4Jaru7GmprFoGzby95rKRprGJCTDjRRnA6l79cClzYMqFKkQKyNeJOroYXHjxc3Tk/yvrUruAsFCU84w4CznxfndOzU9/h4ITfNCopuUFVLft5qaj+4yxzUTB4GRGdzZvfK";
//   private final static String format="json";
//   private final static String character="utf-8";
//   private final static String alipayPublicKey="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAol4SrTwjB6RqSYQKWGiGopysy9KoHluqrsasGqDZWBm8Q4WlDYXpRpV7C53fqbChz/p/VwdGpb+bDSZU9pLEaSCzZTX6JqEeFo2fQav4mRVIY1FPgqOJ5Mn4AN/dB7j45Qy9wrIKh6+nP3dvDiN4wrHiobj4cl8Xb4vxbI3bvbj2SFYeL6u8iO49Hi4oXHvNaNzoKw8tl2hkI8N5sWU4LZAdT8odCSdpWwoMRvAapN+Doa4ceRgBmSc9D6l2qfz8Y0DIjd9wrs2fAc0XUUxb+JG1p5wGnzDagaNxFO8YkfeKlnaLtQ2ELQ2cy25db6sdNihIvXs6J3RzaU9kB4lHZwIDAQAB";
//   private final static String signType="RSA2";
//   private final static String returnUrl="";
//   private final static String notfiyUrl="http://331t2j2729.zicp.vip/notifyUrl";
//
//   public static String createAlipayForm(TbSeckillOrder tbSeckillOrder){
//       AlipayClient alipayClient =  new DefaultAlipayClient( serverUrl , appId, appPrivateKey, format, character, alipayPublicKey, signType);  //获得初始化的AlipayClient
//       AlipayTradePagePayRequest alipayRequest =  new  AlipayTradePagePayRequest(); //创建API对应的request
//       alipayRequest.setReturnUrl( "http://domain.com/CallBack/return_url.jsp" );
//       alipayRequest.setNotifyUrl( notfiyUrl ); //在公共参数中设置回跳和通知地址
//
//      //声明需要支付的对象
//       JSONObject jsonObject = new JSONObject();
//      jsonObject.put("out_trade_no",tbSeckillOrder.getTranscationId());
//       jsonObject.put("product_code","FAST_INSTANT_TRADE_PAY");
//       jsonObject.put("total_amount",tbSeckillOrder.getMoney());
//       jsonObject.put("subject","秒杀商品购买");
//       jsonObject.put("body","秒杀商品购买");
//
//       alipayRequest.setBizContent(jsonObject.toJSONString()); //填充业务参数
//       String form= "" ;
//       try  {
//           form = alipayClient.pageExecute(alipayRequest).getBody();  //调用SDK生成表单
//       }  catch  (AlipayApiException e) {
//          e.printStackTrace();
//       }
//        return form;
//    }
//
//
//   public static Map verfiyAlipayRequest(HttpServletRequest httpServletRequest){
//       //1.将request请求解析为map集合
//       Map<String, String> stringStringMap = convertRequestParamsToMap(httpServletRequest);
//       //2.使用公钥私钥进行解密操作
//      try {
//            boolean signVerified = AlipaySignature.rsaCheckV1(stringStringMap, alipayPublicKey, character, signType); //调用SDK验证签名
//           //如果为true则代表验证成功，直接将map集合返回
//           if (signVerified){
//              return stringStringMap;
//            }
//       } catch (AlipayApiException e) {
//           e.printStackTrace();
//       }
//       return null;
//    }
//
//    // 将request中的参数转换成Map
//   private static Map<String, String> convertRequestParamsToMap(HttpServletRequest request) {
//        Map<String, String> retMap = new HashMap<String, String>();
//
//        Set<Map.Entry<String, String[]>> entrySet = request.getParameterMap().entrySet();
//
//       for (Map.Entry<String, String[]> entry : entrySet) {
//            String name = entry.getKey();
//            String[] values = entry.getValue();
//            int valLen = values.length;
//
//           if (valLen == 1) {
//                retMap.put(name, values[0]);
//            } else if (valLen > 1) {
//               StringBuilder sb = new StringBuilder();
//                for (String val : values) {
//                    sb.append(",").append(val);
//                }
//                retMap.put(name, sb.toString().substring(1));
//            } else {
//                retMap.put(name, "");
//            }
//        }
//
//        return retMap;
//    }
//}
